Skip to content

refactor: make &compilation for optimization_dependencies#12576

Merged
hardfist merged 4 commits intomainfrom
yj/ref-optimize-dependencies
Dec 30, 2025
Merged

refactor: make &compilation for optimization_dependencies#12576
hardfist merged 4 commits intomainfrom
yj/ref-optimize-dependencies

Conversation

@hardfist
Copy link
Contributor

@hardfist hardfist commented Dec 29, 2025

Summary

change &mut compilation to &compilation to avoid direct mutate compilation in optimize_dependencies phase

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings December 29, 2025 08:52
@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 1e0e468
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6953867f6be7d1000866f7a6

@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Dec 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the CompilationOptimizeDependencies hook to accept &Compilation (immutable reference) instead of &mut Compilation (mutable reference), passing BuildModuleGraphArtifact as a separate mutable parameter. This allows better separation of concerns and more granular control over what can be mutated during dependency optimization.

Key Changes:

  • Modified CompilationOptimizeDependencies hook signature to take &Compilation and &mut BuildModuleGraphArtifact separately
  • Removed the Compilation::get_make_module_graph_mut static method in favor of direct access via build_module_graph_artifact.get_module_graph_mut()
  • Updated all plugins implementing the hook to use the new signature

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/rspack_core/src/compilation/mod.rs Updated hook definition, removed static helper method, refactored add_entry and call sites to use direct access pattern
crates/rspack_plugin_progress/src/lib.rs Updated hook implementation signature and added import for BuildModuleGraphArtifact
crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs Updated hook signature and changed to use new artifact parameter for module graph access
crates/rspack_plugin_javascript/src/plugin/inline_exports_plugin.rs Updated hook signature, added import, changed module graph access pattern
crates/rspack_plugin_javascript/src/plugin/flag_dependency_usage_plugin.rs Refactored proxy struct and methods to accept separate compilation and artifact parameters
crates/rspack_plugin_javascript/src/plugin/flag_dependency_exports_plugin.rs Updated to use direct access instead of static method
crates/rspack_plugin_dll/src/flag_all_modules_as_used_plugin.rs Updated hook signature and module graph access
crates/rspack_plugin_rslib/src/import_external.rs Changed from static method to direct access pattern
crates/rspack_plugin_library/src/modern_module_library_plugin.rs Changed from static method to direct access pattern
crates/rspack_plugin_library/src/export_property_library_plugin.rs Changed from static method to direct access pattern
crates/rspack_plugin_library/src/assign_library_plugin.rs Changed from static method to direct access pattern
crates/rspack_plugin_lazy_compilation/src/plugin.rs Changed from static method to direct access pattern
crates/rspack_plugin_esm_library/src/plugin.rs Changed from static method to direct access pattern
crates/rspack_binding_api/src/exports_info.rs Changed from static method to direct access pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

📦 Binary Size-limit

Comparing 1e0e468 to chore: bump swc_core from 52.0.0 to 54.0.0 and swc_experimental from 0.3.5 to 0.4.0 (#12582) by CPunisher

🎉 Size decreased by 1.38KB from 47.85MB to 47.85MB (⬇️0.00%)

@hardfist hardfist marked this pull request as draft December 29, 2025 09:23
@hardfist hardfist force-pushed the yj/ref-optimize-dependencies branch from 7651281 to 1388182 Compare December 29, 2025 15:25
@hardfist hardfist force-pushed the yj/ref-optimize-dependencies branch from 1388182 to b2501aa Compare December 30, 2025 06:39
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (2ecf0ec625) does not have baseline artifacts. Using commit 4a0f619226 for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 823.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB -23.0 B (-0.0%)
ui-components 2.1 MB 0
📋 Detailed Reports (Click to expand)

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 4a0f619226 | PR: #12582

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.4 KB -23.0 B (-0.0%)
📄 JavaScript 984.3 KB 984.4 KB -23.0 B (-0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: rome Bundle Diff

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #12576 will not alter performance

Comparing yj/ref-optimize-dependencies (1e0e468) with main (4a0f619)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@hardfist hardfist marked this pull request as ready for review December 30, 2025 08:30
@hardfist hardfist enabled auto-merge (squash) December 30, 2025 08:32
@hardfist hardfist merged commit c219725 into main Dec 30, 2025
78 of 80 checks passed
@hardfist hardfist deleted the yj/ref-optimize-dependencies branch December 30, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants